﻿using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using IDotNet.MapLibs.BMap.Model;

namespace IDotNet.MapLibs.BMap
{
    public class BMapPlace : IPlace
    {
        public MapLibs.Model.IPlaceSuggestionResModel Suggestion(MapLibs.Model.IPlaceSuggestionReqModel model)
        {
            var param = (BMapPlaceSuggestionReqModel)model;
            var parms = new NameValueCollection
           {
               {"ak",param.ak},
               {"region",param.Region.UrlEncode()},
               {"q",param.Query.UrlEncode()},
               {"output",param.output},
               {"location",param.location==null?null:param.location.ToLatLng()},
           };
            var res = MapLibHelper.GetHttpResult(MapLibConfig.BMap.SuggestionUri, parms,"get");
            return MapLibHelper.ToDeserialize<BMapPlaceSuggestionResModel>(res, param.output == "json");
        }
    }
}
